import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex)
const actions = {
    settoken: function(miniStore, value) {
        miniStore.commit('SETTOKEN', value)
    }
}
const mutations = {
    SETTOKEN: function(state, value) {
        state.token = value
        sessionStorage.token = value
    }
}

const getters = {
    getToken: function(state) {
        if (!state.token) {

            state.token = sessionStorage.getItem('token')
        }

        return state.token
    }
}
const state = {
    token: '',
}
export default new Vuex.Store({
    actions: actions,
    mutations: mutations,
    state: state,
    getters: getters,
})